--[[ 编码: WMS-07-05 名称: 常量-功能按钮-刷新WMS字典常量 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: GenWMSConst 功能: 通过WMS的一些字典定义生成常量,比如 通过 WMS_ScheduleSystemType 生成分组= 调度类型 的常量 更改记录: V2.0 HAN 20250213 -- 新增了 WMS_CountType 盘点类型 --]] wms_base = require ("wms_base") local function Conversion( strLuaDEID, group_name, dict_name ) local nRet, strRetInfo if ( group_name == nil or group_name == '' or dict_name == '' or dict_name == nil ) then return end nRet, strRetInfo = mobox.getDictItemIInfo( dict_name ) if ( nRet ~= 0 or strRetInfo == '') then lua.Error( strLuaDEID, debug.getinfo(1), "系统没有定义名为'"..dict_name.."'的字典!") end local dict_items = json.decode( strRetInfo ) local strCondition = "S_GROUP = '"..group_name.."'" nRet, strRetInfo = mobox.dbdeleteData( strLuaDEID, "WMS_Const", strCondition ) if ( nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "删除【常量】失败! "..strRetInfo ) end local n, nCount nCount = #dict_items for n = 1, nCount do local const = m3.AllocObject( strLuaDEID, "WMS_Const") const.name = group_name..'-'..dict_items[n].value const.value = dict_items[n].name const.group = group_name const.sys = "Y" const.note = "由字典"..dict_name.."生成" nRet, strRetInfo = m3.CreateDataObj(strLuaDEID, const) if (nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"创建WMS常量失败!"..strRetInfo) end end end function GenWMSConst ( strLuaDEID ) local dict_array = {} local nIndex = 1 Conversion( strLuaDEID, "调度类型", "WMS_ScheduleSystemType" ) Conversion( strLuaDEID, "货位类型", "WMS_LocationType" ) Conversion( strLuaDEID, "货位用途", "WMS_LocationPurpose" ) Conversion( strLuaDEID, "接驳类型", "WMS_ConnectType" ) Conversion( strLuaDEID, "库区类型", "WMS_AreaType" ) Conversion( strLuaDEID, "检验类型", "WMS_InspectionType" ) Conversion( strLuaDEID, "任务类型", "WMS_TaskType" ) Conversion( strLuaDEID, "容器类型", "WMS_ContainerType" ) Conversion( strLuaDEID, "设备动作", "WMS_EquipmentAction" ) Conversion( strLuaDEID, "设备类型", "WMS_EquipmentType" ) Conversion( strLuaDEID, "作业状态", "WMS_OperationState" ) Conversion( strLuaDEID, "功能区类型", "WMS_FuncType" ) Conversion( strLuaDEID, "基础类型", "WMS_FAType" ) Conversion( strLuaDEID, "物料状态", "WMS_ItemState" ) Conversion( strLuaDEID, "库区设备类型", "WMS_AreaDevice_Type" ) Conversion( strLuaDEID, "盘点类型", "WMS_CountType" ) end